package com.abhinav.spring;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import com.abhinav.spring.bean.HelloWorld;
import com.abhinav.spring.bean.SingletonBean;
import com.abhinav.spring.config.AppConfig;

public class SpringApp {
	public static void main(String[] args) {
		AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(AppConfig.class);
		ctx.scan("com.abhinav.spring.bean");
		//ctx.refresh();

		HelloWorld hello = (HelloWorld) ctx.getBean("newHelloBean");
		hello.printHello();

		SingletonBean sBean = (SingletonBean) ctx.getBean("singletonBean");
		System.out.println(sBean.getCount());
		System.out.println(sBean.getPrototypeBean().getRandomNum());

		SingletonBean sBean2 = (SingletonBean) ctx.getBean("singletonBean");
		System.out.println(sBean2.getCount());
		System.out.println(sBean2.getPrototypeBean().getRandomNum());

	}

}
